Auto-increment Attribute in SQLite

Auto-increment Attribute in SQLite


SQLite recommends that you should not use Auto-increment attribute, because:

  • The AUTOINCREMENT keyword imposes extra CPU, memory, disk space, and disk I/O overhead.
  • Therefore, it should be avoided if not strictly required.

But if you need, you can use following script:

CREATE TABLE people
(
   PersonID INTEGER PRIMARY KEY AUTOINCREMENT,
   FirstName text NOT NULL,
   LastName text NOT NULL
);

Seyed Hamed Vahedi Seyed Hamed Vahedi     Thu, 28 December, 2017